import input from "./form_item/Input";
import radio from "./form_item/Radio";
import checkBox from "./form_item/CheckBox";
import datePicker from "./form_item/DatePicker";
import image from "./form_item/Image";
import file from "./form_item/File";
import textarea from "./form_item/Textarea";
import select from "./form_item/Select";
import selectBox from "./form_item/SelectBox";
import rate from "./form_item/Rate";
import Switch from "./form_item/Switch";
import slider from "./form_item/Slider";
import vueEditor from "./form_item/VueEditor";

const form_item = {
  input,
  radio,
  checkBox,
  datePicker,
  image,
  file,
  textarea,
  select,
  selectBox,
  rate,
  switch: Switch,
  slider,
  vueEditor
};
export default {
  render(h) {
    return h(
      "el-form-item",
      {
        props: {
          label: this.obj.elementName,
          prop: "sortable_item." + this.index + ".obj.value",
          rules: this.obj.rules.map(v => JSON.parse(v)),
        },
        style: {},
      },
      [form_item[this.ele](this, h)]
    );
  },
  props: {
    ele: {
      type: String,
    },
    obj: {
      type: Object,
    },
    index: {
      type: Number,
    },
  },
};
